package com.gmlive.common.sample.widgets

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.gmlive.common.imageloader.ImageLoader
import com.gmlive.common.imageloader.url.UrlCreate
import com.gmlive.common.sample.R
import kotlinx.android.synthetic.main.activity_image_load.*

/**
 *  Create by: fanfeiyue
 *  on: 2019-11-22
 *  desc:
 */
class ImageLoadDemoActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_image_load)
        val url = "https://s2.ax1x.com/2019/11/22/M7grMF.md.png"
        ImageLoader.load(url).get().into(img_1)

        ImageLoader.load(url).get().getBitmap(1) { _, bitmap -> img_2.setImageBitmap(bitmap) }

        ImageLoader.load(url)
                .setWidthDp(10)
                .setHeightDp(10)
                .setOrigin(UrlCreate.ORIGIN_ORIGIN)
                .get()
                .placeHolder(R.drawable.ic_launcher)
                .error(R.drawable.arrow_left)
                .into(img_3)

        ImageLoader.load(url)
                .get()
                .placeHolder(R.drawable.ic_launcher)
                .error(R.drawable.arrow_left)
                .into(img_4)
    }
}